package niuke;
import java.util.*;
class Word{
    int times;
    String word;
    Word(int times,String word){
        this.times=times;
        this.word=word;
    }
}
public class niuKeMain2 {
    public List<String> topKFrequent(String[] words, int k) {
        HashMap<String,Integer> map=new HashMap<>();
        for (String str:words) {
            if (map.containsKey(str)){
                int value=map.get(str);
                map.put(str,value+1);
            }
            else {
                map.put(str,1);
            }
        }
        List<String> list=new LinkedList<>();
        PriorityQueue<Word> queue=new PriorityQueue<>(new Comparator<Word>() {
            @Override
            public int compare(Word o1, Word o2) {
                if (o1.times==o2.times){
                    return o1.word.compareTo(o2.word);
                }
                return o1.times-o2.times;
            }
        });
        Word[] words1=new Word[map.size()];
        int count=0;
        for (Map.Entry<String,Integer> maps:map.entrySet()) {
            int time=maps.getValue();
            String word=maps.getKey();
            words1[count++]=new Word(time,word);
        }
        for (int i = 0; i < words1.length; i++) {
            if(i<k){
                queue.offer(words1[i]);
            }
            else {
                Word word=queue.peek();
                if (word.times<words1[i].times){
                    queue.poll();
                    queue.offer(words1[i]);
                }
                else if(word.times==words1[i].times){
                    queue.offer(words1[i]);
                }
            }
        }
        String[] str=new String[queue.size()];
        for (int i = 0; i < str.length; i++) {
            str[i]=queue.poll().word;
        }
        for (int i = str.length-1; i >=0&&list.size()<=k; i--) {
            list.add(str[i]);
        }
        return list;
    }
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String str1=in.nextLine();
        String str2=in.nextLine();
        Set<Character> set1=new HashSet<>();
        char[] ch1=str1.toCharArray();
        char[] ch2=str2.toCharArray();
        for (int i = 0; i < ch2.length; i++) {
            if (ch2[i]>='a'&&ch2[i]<='z'){
                ch2[i]=Character.toUpperCase(ch2[i]);
            }
            set1.add(ch2[i]);
        }
        for (int i = 0; i < ch1.length; i++) {
            if (ch1[i]>='a'&&ch1[i]<='z'){
                ch1[i]=Character.toUpperCase(ch1[i]);
            }
            if (!set1.contains(ch1[i])){
                System.out.print(ch1[i]);
                set1.add(ch1[i]);
            }
        }
    }
    public void reorderList(ListNode head) {
        if (head==null){
            return;
        }
        ListNode cur=head;
        int count=0;
        while (cur!=null){
            count++;
            cur=cur.next;
        }
        cur=head;
        ListNode[] arr=new ListNode[count];
        for (int i=0;i<count;i++){
            arr[i]=cur;
            cur=cur.next;
        }
        int start=0;
        int end=arr.length-1;
        while (start<end){
            arr[end].next=arr[start].next;
            arr[start].next=arr[end];
            end--;
            start++;
        }
        arr[start].next=null;
    }
    public int lowestCommonAncestor (treenode root, int o1, int o2) {
        // write code here
        if(root==null){
            return 0;
        }
        if (root.val==o1||root.val==o2){
            return root.val;
        }
        int left=lowestCommonAncestor(root.left,o1,o2);
        int right=lowestCommonAncestor(root.right, o1, o2);
        if (left!=0&&right!=0){
            return root.val;
        }
        if (left!=0&&right==0){
            return left;
        }
        if (left==0&&right!=0){
            return right;
        }
        return 0;
    }
    public int compare (String version1, String version2) {
//         write code here
        String[] str1=version1.split("\\.");
        String[] str2=version2.split("\\.");
        for (int i = 0; i < Math.max(str1.length,str2.length); i++) {
            int sum1=0;
            int sum2=0;
            if (i<str1.length){
                for (int j = 0; j < str1[i].length(); j++) {
                    sum1=sum1*10+str1[i].charAt(j)-'0';
                }
            }
            if (i<str2.length){
                for (int j = 0; j < str2[i].length(); j++) {
                    sum2=sum2*10+str2[i].charAt(j)-'0';
                }
            }
            if (sum1<sum2){
                return -1;
            }
            else if (sum1>sum2){
                return 1;
            }
        }
        return 0;
    }
}
